package com.cd2cd.code_template.controller;

import com.cd2cd.code_template.code_template.domain.SysUser;
import com.cd2cd.code_template.service.LoginService;
import com.cd2cd.code_template.vo.BaseRes;
import com.cd2cd.code_template.vo.LoginResVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 用户登录controller <br>
 * 前端登录时使用验证码类型：图片验证码、短信验证码、Google双因子、图形拖动实现
 */
@Controller
@RequestMapping("comm/login")
public class LoginController {


    @Resource
    private LoginService loginService;

    /**
     * 管理后台登录
     * @return
     */
    @ResponseBody
    @RequestMapping("admin")
    public BaseRes<LoginResVo> adminLogin(@RequestBody SysUser sysUser) {

        return loginService.adminLogin(sysUser.getUsername(), sysUser.getPassword());
    }

    @ResponseBody
    @RequestMapping(value = "system",method = RequestMethod.POST)
    public BaseRes<LoginResVo> systemLogin(@RequestBody SysUser sysUser) {

        return loginService.systemLogin(sysUser);
    }

}
